import { h } from 'vue'
import { Icon } from '@iconify/vue'
import { NIcon } from 'naive-ui'
import SvgIcon from '@/components/icon/SvgIcon.vue'

export enum IconTypeEnum {
  custom = 'custom',
  iconify = 'iconify'
}

export type IconType = (typeof IconTypeEnum)[keyof typeof IconTypeEnum]

export type IconProps = {
  icon: string
  type?: IconType
  size?: number | string
  color?: string
}

export function renderIcon(props: IconProps) {
  return () => h(NIcon, props, { default: () => h(Icon, { icon: props.icon }) })
}

export function renderCustomIcon(props: IconProps) {
  return () => h(NIcon, props, { default: () => h(SvgIcon, { icon: props.icon }) })
}
